package com.example.administrator.x2picturetransliteration.Home.Activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.EditText;
import android.widget.TextView;

import com.example.administrator.x2picturetransliteration.Base.BaseActivity;
import com.example.administrator.x2picturetransliteration.R;
import com.example.administrator.x2picturetransliteration.Util.RegularUtil;
import com.example.administrator.x2picturetransliteration.Util.ToastUtil;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 设置密码
 * Created by Administrator on 2019/9/26.
 */

public class SetPwdActivity extends BaseActivity{

    public static void startSetPwdActivity(Context context){

        ((Activity)context).startActivityForResult(new Intent(context,SetPwdActivity.class),100);

    }

    @BindView(R.id.TitleText)TextView TitleText;
    @BindView(R.id.XPWEdit)EditText XPWEdit;

    @Override
    public int intiLayout() {
        return R.layout.home_activity_set_pwd;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        TitleText.setText("设置密码");
    }

    @OnClick(R.id.OkText)
    public void OkTextClick(){

        if ("".equals(XPWEdit.getText() + "")){

            new ToastUtil(SetPwdActivity.this).getToast(false,"请输入密码").show();

        }else {

            if (RegularUtil.isENG_NUM(XPWEdit.getText() + "") && (XPWEdit.getText() + "").length()>=8 && (XPWEdit.getText() + "").length()<=12){

                Intent intent = new Intent();
                intent.putExtra("pwd",XPWEdit.getText() + "");
                setResult(2, intent);
                finish();

            }else {

                new ToastUtil(this).getToast(false,"密码格式错误").show();

            }
        }

    }

    @Override
    public void onBackPressed() {
        //super.onBackPressed();
    }
}
